<template>
	<view class="goods_detail">
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(item,index) in swiper" :key="index">
				<image :src="item.src" mode=""></image>
			</swiper-item>
			
		</swiper>
		<view class="box1">
			<view class="price">
				<text>￥{{detail.sell_price}}</text>
				<text>￥{{detail.market_price}}</text>
			</view>
			<view class="goods_name">
				{{detail.title}}
			</view> 

		</view>
		
		<view class="line">
			
		</view>
		<view class="box2">
			<view class="">
				货号
				
			</view>
			<view class="">
				存储
			</view>
			
		</view>
		<view class="line">
			
		</view>
		
		<view class="box3">
			<view class="tit">
				详情介绍
				
			</view>
			<view class="content">
				<rich-text :nodes="desc.content"></rich-text>
				
			</view>
			
		</view>
	<view class="goods-carts">
				<uni-goods-nav :options="options" :fill="true" :button-group="buttonGroup" @click="onClick"
					@buttonClick="buttonClick" />
			</view>
		
	</view>
</template>

<script>
	import goodsnav from '@/uni_modules/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue'

	export default {
		data() {
			return {
				goodsid:0,
				swiper:[],
				detail:{},
				desc:{},
				 options: [{
							icon: 'headphones',
							text: '客服'
						}, {
							icon: 'shop',
							text: '店铺',
							info: 2,
							infoBackgroundColor:'#007aff',
							infoColor:"red"
						}, {
							icon: 'cart',
							text: '购物车',
							info: 2
						}],
				buttonGroup: [{
					      text: '加入购物车',
					      backgroundColor: '#ff0000',
					      color: '#fff'
					    },
					    {
					      text: '立即购买',
					      backgroundColor: '#ffa200',
					      color: '#fff'
					    }
					    ]
					  }
			
		},
		onLoad(options) {
			this.goodsid =options.id
			this.getDetailLunbo()
			this.getGoodsDetail()
			this.getGoodsdesc()
			console.log(options);
			
		},
		components:{
			goodsnav
		},
		methods: {
			async getDetailLunbo(){
				const res=await this.$myRequest({
					url:'/api/getthumimages/'+this.goodsid
				})
				
				this.swiper = res.data.message
			},
			
			async getGoodsDetail(){
				const res = await this.$myRequest({
					url:'/api/goods/getinfo/'+this.goodsid
				})
				this.detail = res.data.message[0]
				console.log("this.detail"+this.detail)
			},
			
			async getGoodsdesc(){
				const res = await this.$myRequest({
					url:'/api/goods/getdesc/'+this.goodsid
				})
				
				this.desc = res.data.message[0]
			}
			
		}
	}
</script>

<style lang="scss">
	.goods_detail{
		
		swiper{
			 height: 700rpx;
			 image:{
				 width:100%;
				 height: 100%;
			 }
		}
		.box1{
			padding: 10px;
			.price{
				font-size: 30rpx ;
				color:#f00;
				
				text:nth-child(2){
					color: #ccc;
					font-size: 28rpx;
					margin-left: 20rpx;
					text-decoration: line-through;
				}
			}
			.goods_name{
				font-size: 30rpx;
				line-height: 60rpx;
			}
		}
		
		.line{
			height: 15rpx;
			width: 750rpx;
			background: #eee;
		}
		
		.box2{
			padding: 0 10px;
			font-size: 32rpx;
			line-height: 60rpx;
			
		}
		.box3{
			padding-bottom: 50px;
			.tit{
			 font-size: 32rpx;
			padding-left: 10px;
			border: 1px solid #eee;
			line-height: 60rpx;
			}
			.content{
				padding:10px;
				font-size: 28rpx;
				color: #333;
				
			}
		
			
		}
		.goods-carts{
			position: fixed;
			bottom: 0;
			width: 100%;
		}
		
	}
	
	

</style>
